// 获取配置文件中的模式
const {mode} = require('../../common/getConf');

const versionFile = require('../../common/getVersionFile');

const { P_SERIES, CLOUD, PC, OUTPUT_DIR, OUTPUT_NAME } = require('../../common/constans');

let content = versionFile(mode);

//  p系列的问题
module.exports=[
  {
    step:0,
    question:'请输入平台选项p_series(简写p代替) cloud pc',
    skip:false,
    callback:function(answer,option,cb){
      if(answer === 'p' || answer === P_SERIES || answer === CLOUD || answer === PC){
        if(answer === 'p')answer=P_SERIES;
        option.answer = answer;
        let step = option.step+1;
        let version = content[answer]['version'];
        let lastVersion = content[answer]['last_version'];
        this[step].question=`请输入版本号(当前${version}  上一个版本${lastVersion} 回车跳过)`;
        this[step].answer=version;
        this[step+1].question=`请输入上一个版本号(当前${version}  上一个版本${lastVersion} 回车跳过)`;
        this[step+1].answer=lastVersion;
        cb(step);
      }else{
        console.log('未找到该平台,请重新输入 退出quit 或 ctrl+c')
      }
    },
    answer:null,
    argvName:'platform'
  },
  {
    step:1,
    question:`请输入版本号(回车跳过)`,
    skip:true,
    callback:function(answer,option,cb){
      let step = option.step+1;
      if(answer!==''||answer!==undefined){
        option.answer = answer;
        this[step].question=`请输入上一个版本号(当前${answer}  上一个版本${this[step].answer} 回车跳过)`;
      }
      cb(step);
    },
    answer:null,
    argvName:'version'
  },
  {
    step:2,
    question:`请输入上一个版本号(回车跳过)`,
    skip:true,
    callback:function(answer,option,cb){
      let step = option.step+1;
      if(answer !== ''){
        option.answer = answer;
      }
      cb(step)
    },
    answer:null,
    argvName:'lastVersion'
  },
  {
    step:3,
    question:'请输入输出文件路径,不设置将使用配置文件选项(回车跳过)',
    skip:true,
    answer:null,
    argvName:OUTPUT_DIR
  },
  {
    step:4,
    question:'输出文件名，不设置将使用默认规则(回车跳过)',
    skip:true,
    answer:null,
    argvName:OUTPUT_NAME
  },
  {
    step:5,
    question:'输入备注(回车跳过)',
    skip:true,
    answer:null,
    argvName:'memo'
  }
]